package web;

import pojo.Category;
import service.CategoryService;
import service.Impl.CategoryServiceImpl;
import utils.JsonUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/category")
public class CategoryServlet extends BaseServlet {
    public void findAllCategory(HttpServletRequest request,HttpServletResponse response) throws IOException {
        CategoryService categoryService = new CategoryServiceImpl() ;
        List<Category> cList = categoryService.getAllCategory() ;
        String jsonStr = JsonUtils.list2json(cList);
        System.out.println(jsonStr);

        response.getWriter().write(jsonStr);
    }
}
